<?php

namespace App\Http\Controllers\Api\Sign;

use App\Http\Controllers\Api\Controller;
use Illuminate\Http\Request;
use App\Models\Sign\Project;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use App\Http\Requests\Api\SignUserRequest;
use App\Models\Sign\SignUser;

class ProjectController extends Controller
{
    //专业(联动信息)
    public function getProjectMsg()
    {

        $project_data = DB::table('sign_projects')->select('id','pid','name')->get();

        $message = [];
        foreach ($project_data as $key=>$val){
            $message[$val->id]['id'] = $val->id;
            $message[$val->id]['pid'] = $val->pid;
            $message[$val->id]['name'] = $val->name;
        }


        //树形-联动
        $project_msg = [];
        foreach ($message as $key=>$value){

            if($value['pid'] == 0 ){
                $project_msg[] = &$message[$value['id']];
            }else{
                $message[$value['pid']]['son'][] = &$message[$value['id']];
            }
        }

        return $this->success($project_msg);
    }








}
